/**
 * @Author: LongTao
 * @program: day04_longtao_springmvc_1917JA_20210108
 * @description:
 * @create: 2021-01-19 21:07
 * @version:1.0
 **/
package com.springmvc.longtao.smbms.service.impl;

import com.github.pagehelper.PageHelper;
import com.springmvc.longtao.smbms.dao.BillMapper;
import com.springmvc.longtao.smbms.dao.ProviderMapper;
import com.springmvc.longtao.smbms.pojo.Bill;
import com.springmvc.longtao.smbms.pojo.Provider;
import com.springmvc.longtao.smbms.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BillServiceImpl implements BillService {
    /**
     * 注入订单接口类
     */
    private BillMapper billMapper;

    @Autowired
    @Qualifier("billMapper")
    public void setBillMapper(BillMapper billMapper) {
        this.billMapper = billMapper;
    }

    /**
     * 注入供应商接口类
     */
    private ProviderMapper providerMapper;
    @Autowired
    @Qualifier("providerMapper")
    public void setProviderMapper(ProviderMapper providerMapper) {
        this.providerMapper = providerMapper;
    }




    /**
     * 增加订单
     *
     * @param bill
     * @return
     */
    @Override
    public boolean add(Bill bill) {
        boolean flag=false;
        if (billMapper.add(bill)>0){
            flag=true;
        }
        return flag;
    }

    /**
     * 通过条件获取订单列表-模糊查询-billList
     *
     * @param bill
     * @return
     */
    @Override
    public List<Bill> getBillList(Bill bill, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Bill> list = billMapper.getBillList(bill);
        return list;
    }

    /**
     * 通过billId删除Bill
     *
     * @param delId
     * @return
     */
    @Override
    public boolean deleteBillById(String delId) {
        return false;
    }

    /**
     * 通过billId获取Bill
     *
     * @param id
     * @return
     */
    @Override
    public Bill getBillById(String id) {
        return null;
    }

    /**
     * 修改订单信息
     *
     * @param bill
     * @return
     */
    @Override
    public boolean modify(Bill bill) {
        boolean flag=false;
        if (billMapper.modify(bill)>0){
        flag=true;
        }
        return flag;
    }

    /**
     * 查询供应商
     *
     * @return
     */
    @Override
    public List<Provider> getProviderList() {
        return providerMapper.getProviderList();
    }

    /**
     * 根据billCode来查询,验证billCode是否唯一
     *
     * @param billCode
     * @return
     */
    @Override
    public Bill getBill(String billCode) {
        return billMapper.getBill(billCode);
    }

    /**
     * 根据id来查询商品表
     *
     * @param id
     * @return
     */
    @Override
    public Bill getBillID(String id) {
        return billMapper.getBillID(id);
    }
}